import java.util.HashMap;

/**
* @description: 周赛309 t1
* @author hewei
* @date 2022/9/4 10:31
* @version 1.0
*/

public class CheckDistances {

    public boolean checkDistances(String s, int[] distance) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            int index = s.charAt(i) - 'a';
            if (map.containsKey(index)) {
                if (distance[index] != i - map.get(index) - 1) return false;
            } else {
                map.put(index, i);
            }
        }
        return true;
    }
}
